#
# LEncoderTrackDrag.py
#
# This work is released under the GNU GPL, version 2 or later.
#
from qt import QStoredDrag

_encodertrackmimetype = 'application/x-encodertrack'

#
# this class encapsulates a drag from a track list - all that's transferred
# is a list of trackIDs
#
class LEncoderTrackDrag(QStoredDrag):
	def __init__(self,trackIDs,widget):
		QStoredDrag.__init__(self,_encodertrackmimetype,widget)
		packet = {'TrackIDs':trackIDs}
		self.setEncodedData(str(packet))
		print "encoded drag",packet

	def trackIDs(self):
		packet = eval(self,encodedData(_encodertrackmimetype))
		return packet['TrackIDs']
	
	def class_canDecode(cls,event):
		return event.provides(_encodertrackmimetype)

	canDecode = classmethod(class_canDecode)

	def class_decode(cls,event):
		return eval(str(event.encodedData(_encodertrackmimetype)))

	decode = classmethod(class_decode)
